//
//  YZFControllerManager.h
//  YZMicroStock
//
//  Created by wangminhong on 16/3/21.
//  Copyright © 2016年 cqjr. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "YZMViewControllerSetting.h"
#import <UIKit/UIKit.h>

#define YZMCMInstance [YZMControllerManager sharedManager]
#define sYZMUnShowGuidePageFlagDefault   @"YZMUnShowGuidePageFlagDefault"
#define sYZMAppCurrentBuildVersionDefault       @"YZMAppCurrentBuildVersionDefault"

@interface YZMControllerManager : NSObject

@property (nonatomic, strong, readonly) UITabBarController *rootTabBarCtrl;

+ (instancetype)sharedManager;

+ (void)initAndEnter;

- (void)moveToMain;

- (UINavigationController *)currentNavationCtroller;

- (Class)classForControllerName:(NSString *)name;

//timer task
- (void)startTimerTask;
- (void)stopTimerTask;

//wangmh remark 快捷支付跳转到外部浏览器
////充值校验
//- (void)rechargeCheckTask;

//instance op
- (void)pushViewController: (id)ctrl animated: (BOOL)animated;
- (void)popViewController: (id)ctrl;

//name op
- (void)pushViewControllerWithName: (NSString *)name andParams: (NSDictionary *)params;

//pushWithNameAndParams
- (void)pushAfterRootWithNameAndParams: (NSArray *)nameAndParams;

- (void)pushAfterName: (NSString *)frontName withControllerName:(NSString *)name andParams: (NSDictionary *)params;

- (void)pushBeforeName: (NSString *)frontName withControllerName:(NSString *)name andParams: (NSDictionary *)params;

- (void)pushAfterTarget: (id)front withControllerName:(NSString *)name andParams: (NSDictionary *)params;

- (void)popViewController;

- (void)popToRootViewController;

- (void)silentPopToRootViewControllerAtIndex: (NSInteger)index;

- (void)presentViewControllerWithName: (NSString *)name andParams: (NSDictionary *)params;

//在指定下标的首页后面展示页面
- (void)pushAfterRootWithName: (NSString *)name andParams: (NSDictionary *)params atIndex: (NSInteger)index;
- (void)setAfterRootWithName: (NSString *)name andParams: (NSDictionary *)params atIndex: (NSInteger)index;

- (void)pushAfterRootWithNames: (NSArray *)names andParams: (NSArray *)paramArray atIndex: (NSInteger)index;

//回到tab当前的根页面
- (void)popViewToRootControllerAnimated: (BOOL)animated;

//清除指定tab的页面，保留root
- (void)clearControllerAtTabIndex: (NSInteger)index;

//查找对应实例或其子类
- (id)substanceWithControllerName: (NSString *)name;

//查找对应实例
- (id)instanceWithControllerName: (NSString *)name;


//跳到指定的类名对应实例
- (void)popViewControllerToControllerName: (NSString *)ctrlName animated: (BOOL)animated;

//跳到指定的类名对应实例之前的页面
- (void)popViewControllerBeforeControllerName:(NSString *)ctrlName animated:(BOOL)animated;

//跳出到指定实例
- (void)popViewController: (id)ctrl animated: (BOOL)animated;


- (void)presentViewController: (id)ctrl;


- (void)dismissViewControllerComplete: (void(^)())complete;

- (void)dismissViewController;

- (UIViewController *)viewControllerForName: (NSString *)name withParams: (NSDictionary *)params;

#pragma mark - fake methods
- (void)pushByCheckingAuthWithName:(NSString *)name andParams:(NSDictionary *)params;

@end
